import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Laser here.
 * 
 * @author (Fco Fernando Gosch Acosta) 
 * @version (1.0)
 */
public class Laser extends Armas
{
    protected int danio;
    protected SimpleTimer gravita;
    protected int lapsoGravita;    
       
    /**
     * Constructor para la clase Laser
     * 
     * daño y vida se asignan sus valores iniciales
     *
     */
    public Laser(int unGrado)
    {
        super(100, unGrado);
        danio = 50;  
        gravita = new SimpleTimer();
        gravita.mark();
        lapsoGravita = 200;
    }
    
    /**
     * Act - do whatever the Laser wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {        
        Pulido p = (Pulido) getOneIntersectingObject(Pulido.class);
        Grande g = (Grande) getOneIntersectingObject(Grande.class);
        Metal m = (Metal) getOneIntersectingObject(Metal.class);
        Pequenio pe = (Pequenio) getOneIntersectingObject(Pequenio.class);
        
        if(p!=null){
            p.reciveDanio((danio  * 3));
        }
        
        else if(g!=null){
            g.reciveDanio((danio * 4 ));
        }
        
        else if(m!=null){
           m.reciveDanio(danio * 2);
        }
        
        else if(pe!=null){
            pe.reciveDanio(danio * 2);
        }
        
        if(rotacion.millisElapsed() > lapsoRotacion )
        {
            gravita();
            rotacion.mark();
        }  
        
        if(gravita.millisElapsed() > lapsoGravita)
        {
                gradosPosicion = (gradosPosicion + 45) % 360;
                gravita.mark();
        }
        
    }    
}
